use std::slice::range;

struct Solution {}

fn main() {}

impl Solution {
    pub fn replace_elements(arr: Vec<i32>) -> Vec<i32> {
        let mut result = vec![];
        let mut cur_max = 0;
        for idx in (1..arr.len()).rev() {
            if arr[idx] > cur_max {
                cur_max = arr[idx].clone();
            }
            result.push(cur_max.clone());
        }
        result.reverse();
        result.push(-1);
        result
    }
}